package com.xhu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xhu.common.request.Page;
import com.xhu.common.request.SaleAnalysisReq;
import com.xhu.pojo.SaleAnalysis;
import com.xhu.service.SaleAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/analysis")
public class SaleAnalysisController extends MyBaseController {

    @Autowired
    SaleAnalysisService service;

    @PostMapping("/getall")
    public String getAll(@RequestBody Page page) {
        IPage<SaleAnalysis> res = service.getAllByPage(page.getCurrent(), page.getSize());
        return this.returnPages(res);
    }

    @PostMapping("/getbymonth")
    public String getByMonth(@RequestBody SaleAnalysisReq req) {
        IPage<SaleAnalysis> res = service.getAllByMonth(req.getCurrent(), req.getSize(), req.getMonth());

        return this.returnPages(res);
    }
}
